package untils

import (
	"doctor-srv/basic/config"
	"fmt"
	"time"
)

// 添加锁
func LockDoctorNum(doctorId, num int) bool {
	key := fmt.Sprintf("doctorId:%d", doctorId)
	_, err := config.Rdb.SetNX(config.Ctx, key, num, time.Second*5).Result()
	if err != nil {
		return false
	}
	return true
}

// 删除锁
func UnLockDoctorNum(doctorId int) bool {
	key := fmt.Sprintf("doctorId:%d", doctorId)
	_, err := config.Rdb.Del(config.Ctx, key).Result()
	if err != nil {
		return false
	}
	return true
}
